package com.king.astro.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.king.astro.R;

public class Astro12 extends Activity implements OnClickListener {
	private TextView tvAstro1;
	private TextView tvAstro2;
	private TextView tvAstro3;
	private TextView tvAstro4;
	private TextView tvAstro5;
	private TextView tvAstro6;
	private TextView tvAstro7;
	private TextView tvAstro8;
	private TextView tvAstro9;
	private TextView tvAstro10;
	private TextView tvAstro11;
	private TextView tvAstro12;

	private TextView tvs[] = { tvAstro1, tvAstro2, tvAstro3, tvAstro4,
			tvAstro5, tvAstro6, tvAstro7, tvAstro8, tvAstro9, tvAstro10,
			tvAstro11, tvAstro12 };

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.astro12);
		initUI();
	}

	private void initUI() {
		for (int i = 0; i < 12; i++) {
			tvs[i] = (TextView) findViewById(getResId(i));
			tvs[i].setOnClickListener(this);
		}
	}

	private int getResId(int index) {
		index = index + 1;
		int id = getResources().getIdentifier("tv_astro_" + index, "id",
				getPackageName());
		return id;

	}

	@Override
	public void onClick(View v) {
		int id = v.getId();
		for (int i = 0; i < 12; i++) {
			if (id == getResId(i))
				startActivity(new Intent(Astro12.this, AstroInfo.class));
		}

	}
}
